﻿<phone:PhoneApplicationPage 
    x:Class="Experiments.MichaelKappel.Net.Tilt.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,0,0,10">
            <TextBlock x:Name="ApplicationTitle" Text="Michael Kappel, MCPD" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Accelerometer" Margin="0,-25,0,0" Padding="0,0,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>
        
        <Grid Loaded="ContentPanel_Loaded" x:Name="ContentPanel" Grid.Row="1" Margin="12,-40,12,0">
            <StackPanel>
                <Canvas x:Name="cvsMain" Height="161" Margin="0,5,0,280">
                    <Image Source="Images/arrows.png" Width="460" Height="460" Visibility="Visible" x:Name="imgXDegree" Canvas.Left="0" Canvas.Top="0" Canvas.ZIndex="4" d:IsLocked="True"   />
                    <Image Source="Images/arrowsWhite.png" Width="460" Height="460" Visibility="Collapsed" x:Name="imgXDegreeWhite" Canvas.Left="0" Canvas.Top="0" Canvas.ZIndex="4" d:IsLocked="True"   />
                    <Image Source="Images/arrowsX.png" Width="400" Height="400" Visibility="Visible" x:Name="imgSymbolX" Canvas.Left="32" Canvas.Top="30" Canvas.ZIndex="3" d:IsLocked="True"   >
                        <Image.Projection>
                            <PlaneProjection x:Name="ppSymbolX" />
                        </Image.Projection>
                    </Image>

                    <Image Source="Images/arrowsY.png" Width="400" Height="400" Visibility="Visible" x:Name="imgSymbolY" Canvas.Left="32" Canvas.Top="30" Canvas.ZIndex="2" d:IsLocked="True"   >
                        <Image.Projection>
                            <PlaneProjection x:Name="ppSymbolY" />
                        </Image.Projection>
                    </Image>

                    <Image Source="Images/arrowsZ.png" Width="400" Height="400" Visibility="Visible" x:Name="imgSymbolZ" Canvas.Left="32" Canvas.Top="30" Canvas.ZIndex="1" d:IsLocked="True">
                        <Image.Projection>
                            <PlaneProjection x:Name="ppSymbolZ" />
                        </Image.Projection>
                    </Image>
                    <Grid x:Name="grdTop" Canvas.ZIndex="1200" Margin="0,10,0,0" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="70" />
                            <RowDefinition Height="335" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="220" />
                            <ColumnDefinition Width="220" />
                        </Grid.ColumnDefinitions>
                        <Button Click="btnReset_Click" Margin="0,0,0,0" Grid.Row="0" Grid.Column="0" x:Name="btnReset" VerticalAlignment="Top" BorderThickness="1" Foreground="DarkGray" BorderBrush="DarkGray" Content="Reset" Height="70" HorizontalAlignment="Left" Padding="0" Width="120" FontSize="20" />
                        <Button Click="btnCalabrate_Click" Margin="0,0,-10,0" Grid.Row="0" Grid.Column="1" x:Name="btnCalabrate" VerticalAlignment="Top" BorderThickness="1" Foreground="DarkGray" BorderBrush="DarkGray" Content="Calibrate" Height="70" HorizontalAlignment="Right" Padding="0" Width="120" FontSize="20" />

                        <TextBlock Grid.Row="2" Grid.Column="2" x:Name="lblVersion" VerticalAlignment="Bottom" HorizontalAlignment="Right"  FontSize="18">Version 2.3</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="2" x:Name="lblEditingX" VerticalAlignment="Bottom" HorizontalAlignment="Right"  FontSize="24" Foreground="Red" Visibility="Collapsed">Editing X</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="2" x:Name="lblEditingY" VerticalAlignment="Bottom" HorizontalAlignment="Right"  FontSize="24" Foreground="Green" Visibility="Collapsed">Editing Y</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="2" x:Name="lblEditingZ" VerticalAlignment="Bottom" HorizontalAlignment="Right"  FontSize="24" Foreground="Blue" Visibility="Collapsed">Editing Z</TextBlock>
                    </Grid>
                </Canvas>

                <StackPanel x:Name="spTabs" Orientation="Horizontal" Margin="0,-6,0,-8">
                    <Button x:Name="btnDefault" Click="btnDefault_Click" Margin="0,0,0,0" Padding="0" Width="140" BorderThickness="1" Content="Default" Foreground="DarkGray" BorderBrush="DarkGray" />
                    <Button x:Name="btnX" VerticalAlignment="Bottom" Click="btnX_Click" Margin="0,0,0,0" Padding="0" Width="100" BorderThickness="1" Content="X" Foreground="DarkGray" BorderBrush="Red" />
                    <Button x:Name="btnY" VerticalAlignment="Bottom" Click="btnY_Click" Margin="0,0,0,0" Padding="0" Width="100" BorderThickness="1" Content="Y" Foreground="DarkGray" BorderBrush="Green" />
                    <Button x:Name="btnZ" VerticalAlignment="Bottom" Click="btnZ_Click" Margin="0,0,0,0" Padding="0" Width="100" BorderThickness="1" Content="Z" Foreground="DarkGray" BorderBrush="Blue" />
                </StackPanel>
                <Grid x:Name="grdControls" Visibility="Collapsed" Margin="0,-5,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="23" />
                        <RowDefinition Height="66" />
                        <RowDefinition Height="63" />
                        <RowDefinition Height="63" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0" />
                        <ColumnDefinition Width="80" />
                        <ColumnDefinition Width="0" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="60" />
                    </Grid.ColumnDefinitions>
  
                    <Button x:Name="btnMappingZ" Click="btnMappingZ_Click" Foreground="Blue" BorderThickness="2" BorderBrush="Blue" Content="Z=Z" Grid.Row="3" Grid.Column="1" Height="70" HorizontalAlignment="Left" Margin="-10,0,0,0" Padding="0" VerticalAlignment="Center" Width="100" />
                    <StackPanel Margin="10,40,0,0" Orientation="Horizontal"  Grid.Row="3" Grid.Column="3" >
                        <TextBlock  Foreground="Blue" Text="Final:" FontSize="14"   />
                        <TextBlock  x:Name="txtZDegreeFinal" Foreground="Blue" FontSize="14"   Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Blue" Text=" Original:" FontSize="14"   />
                        <TextBlock  x:Name="txtZDegree" Foreground="Blue" FontSize="14"  Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Blue" Text=" Raw:" FontSize="14"   />
                        <TextBlock  x:Name="txtZ" Foreground="Blue" FontSize="14"   Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Blue" Text=" Offset:" FontSize="14"   />
                        <TextBlock  x:Name="txtZDegreeOffset" Foreground="Blue" FontSize="14"   Width="35" TextAlignment="Left"  />
                    </StackPanel>
                    <Slider  Margin="0,0,0,0" x:Name="sZ"  Grid.Row="3" Grid.Column="3" Height="84" Width="320" HorizontalAlignment="Right"  Value="2" Foreground="Blue"  Background="Blue" Minimum="0" Maximum="360" />
                    <CheckBox x:Name="cbxInvertZ" Click="cbxInvertZ_Click" VerticalAlignment="Top" Background="Blue" BorderBrush="Blue" BorderThickness="1" Grid.Row="3" Grid.Column="4" />

                    <Button x:Name="btnMappingY" Click="btnMappingY_Click" Foreground="Green" BorderThickness="2" BorderBrush="Green" Content="Y=Y" Grid.Row="2" Grid.Column="1" Height="70" HorizontalAlignment="Left" Margin="-10,0,0,0" Padding="0" VerticalAlignment="Center" Width="100" />
                    <StackPanel Margin="10,40,0,0" Orientation="Horizontal"  Grid.Row="2" Grid.Column="3" >
                        <TextBlock  Foreground="Green" Text="Final:" FontSize="14"   />
                        <TextBlock  x:Name="txtYDegreeFinal" Foreground="Green" FontSize="14"  Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Green" Text=" Original:" FontSize="14"   />
                        <TextBlock  x:Name="txtYDegree" Foreground="Green" FontSize="14"   Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Green" Text=" Raw:" FontSize="14"   />
                        <TextBlock  x:Name="txtY" Foreground="Green" FontSize="14"  Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Green" Text=" Offset:" FontSize="14"   />
                        <TextBlock  x:Name="txtYDegreeOffset" Foreground="Green" FontSize="14"  Width="35" TextAlignment="Left"  />
                    </StackPanel>
                    <Slider  Margin="0,0,0,0" x:Name="sY" Grid.Row="2" Grid.Column="3" Height="84" Width="320" HorizontalAlignment="Right"  Value="3" Foreground="Green" Background="Green" Minimum="0" Maximum="360" />
                    <CheckBox x:Name="cbxInvertY" Click="cbxInvertY_Click" VerticalAlignment="Top" Background="Green" Grid.Row="2" Grid.Column="4" />

                    <Button x:Name="btnMappingX"  Click="btnMappingX_Click" Foreground="Red" BorderThickness="2" BorderBrush="Red" Content="X=X" Grid.Row="1" Grid.Column="1" Height="70" HorizontalAlignment="Left" Margin="-10,0,0,0" Padding="0"  VerticalAlignment="Center" Width="100" />
                    <StackPanel Margin="10,40,0,0" Orientation="Horizontal"  Grid.Row="1" Grid.Column="3" >
                        <TextBlock  Foreground="Red" Text="Final:" FontSize="14"   />
                        <TextBlock  x:Name="txtXDegreeFinal" Foreground="Red" FontSize="14"  Width="35" TextAlignment="Left"  />
                        <TextBlock  Foreground="Red" Text=" Original:" FontSize="14"   />
                        <TextBlock  x:Name="txtXDegree" Foreground="Red" FontSize="14"  Width="35" TextAlignment="Left"   />
                        <TextBlock  Foreground="Red" Text=" Raw:" FontSize="14"   />
                        <TextBlock  x:Name="txtX" Foreground="Red" FontSize="14" Width="35" TextAlignment="Left"   />
                        <TextBlock  Foreground="Red" Text=" Offset:" FontSize="14"   />
                        <TextBlock  x:Name="txtXDegreeOffset" Foreground="Red" FontSize="14"  Width="35" TextAlignment="Left"  />
                    </StackPanel>
                    <Slider Margin="0,0,0,0" x:Name="sX" Grid.Row="1" Grid.Column="3"  Height="84" Width="320" HorizontalAlignment="Right" Value="3" Foreground="Red" Background="Red" Minimum="0" Maximum="360"  />
                    <CheckBox x:Name="cbxInvertX" Click="cbxInvertX_Click" VerticalAlignment="Top" Background="Red" Grid.Row="1" Grid.Column="4" />

                    <TextBlock Margin="0,0,0,0" Canvas.ZIndex="1400" FontSize="18" Foreground="Gray" Grid.Row="0" Grid.Column="1" Text="Mapping" HorizontalAlignment="Left"></TextBlock>
                    <TextBlock Margin="0,0,0,0" FontSize="18" Foreground="Gray" Grid.Row="0" Grid.Column="3" Text="Offset" HorizontalAlignment="Center"></TextBlock>
                    <TextBlock Margin="0,0,0,0" FontSize="18" Foreground="Gray" Grid.Row="0" Grid.Column="4" Text="Inverse" HorizontalAlignment="Right"></TextBlock>

                </Grid>
                <Grid x:Name="grdDefault">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="23" />
                        <RowDefinition Height="55" />
                        <RowDefinition Height="55" />
                        <RowDefinition Height="55" />
                        <RowDefinition Height="20" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70" />
                        <ColumnDefinition Width="80" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="18" Foreground="Gray">Axis</TextBlock>
                    <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="18" Foreground="Gray">Visible</TextBlock>
                    <TextBlock Grid.Row="0" Grid.Column="2" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="18" Foreground="Gray">Degrees</TextBlock>
                    <TextBlock Grid.Row="0" Grid.Column="3" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="18" Foreground="Gray">Raw</TextBlock>


                    <TextBlock  Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Red">X</TextBlock>
                    <CheckBox x:Name="cbxXVisible" Click="cbxXVisible_Click" IsChecked="True" Background="Red" Grid.Row="1" Grid.Column="1" />
                    <TextBlock x:Name="txtXRawDegree" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Red">X</TextBlock>
                    <TextBlock x:Name="txtXRaw"  Grid.Row="1" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Red">X</TextBlock>


                    <TextBlock Grid.Row="2" Grid.Column="0"  HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Green">Y</TextBlock>
                    <CheckBox x:Name="cbxYVisible"   Click="cbxYVisible_Click" IsChecked="True" Background="Green" Grid.Row="2" Grid.Column="1" />
                    <TextBlock x:Name="txtYRawDegree" Grid.Row="2" Grid.Column="2"  HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Green">Y</TextBlock>
                    <TextBlock x:Name="txtYRaw"  Grid.Row="2" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Green">X</TextBlock>

                    <TextBlock  Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Blue">Z</TextBlock>
                    <CheckBox x:Name="cbxZVisible" Click="cbxZVisible_Click" IsChecked="True" Background="Blue" Grid.Row="3" Grid.Column="1" />
                    <TextBlock x:Name="txtZRawDegree" Grid.Row="3" Grid.Column="2"  HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Blue">Y</TextBlock>
                    <TextBlock x:Name="txtZRaw"  Grid.Row="3" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="32" Foreground="Blue">X</TextBlock>

                    <TextBlock x:Name="txtCodePlex"  Margin="0,-16,0,0" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="18" Foreground="Gray" >http://Accelerometer.Codeplex.com/</TextBlock>
                </Grid>
            </StackPanel>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>